#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import sys
import MySQLdb

host=sys.argv[1]
port=sys.argv[2]
user=sys.argv[3]
password=sys.argv[4]
db=sys.argv[5]
# day=sys.argv[6]
columns=sys.argv[6]
table=sys.argv[7]

conn = MySQLdb.connect(host,user,password,db)
cursor = conn.cursor()
if table=="nas_conversion_time" or table=="nas_conversion_pagenum":
    count=cursor.execute("select %s from %s where cid is not null and sid is not null and ison=1" % (columns,table))
else:
    count=cursor.execute("select %s from %s where cid is not null and sid is not null" % (columns,table))

result=cursor.fetchall()

for line in result:
    print "\001".join(list(map(str,line)))
